<script type="text/javascript" src="../javascript/jquery.dataTables.min.js"></script>
<script src="CMS/js/recordset.js" type="text/javascript"></script>
<h2>Registros</h2>
{if $content|count>0}
<table id="recordset">
    <thead>
        <tr>
            {if $actionsAll|count > 0}
            <th><a href="#" onclick="checkAll();">ALL</a>/<a href="#" onclick="uncheckAll();">NONE</a></th>
            {/if}
            {foreach from=$headers item=header}
            <th>{$header}</th>
            {/foreach}
            {if !empty($actions)}
            <th id="actions" colspan="{$actions|count}">Actions</th>
            {/if}
        </tr>
    </thead>
	<form id="formRecordset" name="formRecordset" action="" method="post">
        <tbody>
            {foreach from=$content item=row key=key}
            <tr class="row" id="{$row.$id}">
                {if $actionsAll|count > 0}
                <td style="text-align:center;"><input id="checkbox_{$row.$id}" name="recordsetRow[{$row.$id}]" type="checkbox"></td>
                {/if}
                {foreach from=$row item=cell key=key2}
                {if $key2 != $id}
                {if $booleanColumns.$key2 != true}
                <td>
                    {if is_array($cell)}
                    {foreach from=$cell item='val'}
                    |{$val}
                    {/foreach}
                    {else}
                    {$cell}
                    {/if}
                </td>
                {else}
                <td class="boolean">
                    {if $cell == 1}
                    <div class="true">true</div>
                    {else}
                    <div class="false">false</div>
                    {/if}
                </td>
                {/if}
                {/if}
                {/foreach}
                {if !empty($actions)}
                {foreach from=$actions item=action}
                {if $action.action == 'delete'}
                {assign var='onclick' value="return confirm('¿Estás seguro que quieres borrar este elemento?')"}
                {else}
                {assign var='onclick' value=""}
                {/if}
                <td class="{$action.action} cellAction"><a href="?module={$smarty.get.module}&action={$action.action}&id={$row.$id}" onclick="{$onclick}" class="action" target="{$action.target}">{$action.action}</a></td>
                {/foreach}
                {/if}
            </tr>
            {/foreach}
            {if $actionsAll|count > 0}
            <tr>
                <td>
                    <span>Para los elementos que están marcados:</span>
                    {foreach from=$actionsAll item='action'}
                    <input type="submit" name="actionAll" value="{$action.action}">
                    {/foreach}
                </td>
            </tr>
            {/if}
        </tbody>
	</form>
</table>
{else}
<p>No hay registros</p>
{/if}